<%--
  Created by IntelliJ IDEA.
  User: sunshuo
  Date: 2021/11/8
  Time: 9:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String roleId = request.getParameter("id");
%>
<html>
<head>
    <title>角色授权</title>
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
</head>
<body>
<div id="content" >

</div>

<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
<script src="/js/jquery-2.2.4.js"></script>
<script>
    var id = '<%=roleId%>';
    var tree = layui.tree;
    var treeObj;
    $.ajax({
        type :"post",
        url: "/menu/query_role_auth_tree",
        data :{
            roleId: id
        },
        dataType:"json",
        success:function (data) {
            renderTree(data);
        }
    });

    function renderTree(data) {
        //渲染
        treeObj = tree.render({
            elem: '#content'  //绑定元素
            ,showCheckbox: true
            ,data: data || []
        });
    }

    function getData() {
        return treeObj.getChecked('#content');
    }
</script>
</body>
</html>
